//me.js
const util = require('../../utils/util.js')
var app = getApp();
Page({
    data: {
      cellList: [
        {image: '../../image/mine/published.png', title: '已发布'},
        { image: '../../image/mine/draftsImage.png', title: '草稿箱'},
        { image: '../../image/mine/shelvesDowns.png', title: '已下架'},
        { image: '../../image/mine/bindPhone.png', title: '手机号'},
      ],
      tabbars: [
        { title: '首页', icon: '/image/tab/squareNoSelect.png', color: '#000000' },
        { title: '创作', icon: '/image/tab/createImage.png', color: '#000000' },
        { title: '我的', icon: '/image/tab/mineSelect.png', color: '#0084ff' }]
    },
    onLoad: function () {
      var that = this
      console.log('获取头像和昵称' + app.globalData.userInfo)
      // 检测是否存在用户信息
      if (app.globalData.userInfo != null) {
        that.setData({
          userInfo: app.globalData.userInfo
        })
      } else {
        app.getUserInfo()
      }
    },
    //tabbar的点击事件
    tabbarClick: function (event) {
      console.log('切换tab' + event.currentTarget.dataset.idx)
      if (event.currentTarget.dataset.idx == 0) {
        //首页
        wx.reLaunch({
          url: '../home/home'
        })
      } else if (event.currentTarget.dataset.idx == 1) {
        //创作
        wx.navigateTo({
          url: '../production/production?receiveModel=' + '',
        })
      } else {
        //我的
 
      }
    },
    //列表点击
    cellClick: function (e) {
      console.log('当前点击的id是',e.currentTarget.dataset.idx)
      if (e.target.dataset.idx==3){
        //手机号
          wx.navigateTo({
            url: '../bindPhone/bindPhone?phone=' + util.userPhone
          })
      }else{
        wx.navigateTo({
          // url: `../soldOut/soldOut?type=${e.target.dataset.idx}`
          url: '../soldOut/soldOut?type=' + e.target.dataset.idx
        })
      }

    },
})
